local OVALE, Ovale = ...
local OvaleScripts = Ovale.OvaleScripts

do
	local name = "simulationcraft_priest_discipline_t17m_heal"
	local desc = "[6.1] Attimod: Priest_Discipline_T17M_Heal"
	local code = [[
# Based on SimulationCraft profile "Priest_Discipline_T17M_Heal".
#	class=priest
#	spec=discipline
#	talents=3223232
#	glyphs=prayer_of_-/circle_of_healing/deep_wells7
Include(ovale_common)
Include(ovale_trinkets_mop)
Include(ovale_trinkets_wod)
Include(ovale_priest_spells)

Define(angelic_feather 121536)
Define(angelic_feather_buff 121557)
Define(glyph_of_penance 119866)

AddCheckBox(opt_interrupt L(interrupt) default specialization=discipline)
AddCheckBox(opt_auto_target autoTarget default specialization=discipline)
AddCheckBox(opt_auto_movebuff autoMoveBuff specialization=discipline)
AddCheckBox(opt_auto_autoattack autoAttack specialization=discipline)



AddFunction DisciplineInterruptActions
{
	if CheckBoxOn(opt_interrupt) and not target.IsFriend() and target.IsInterruptible()
	{
		Spell(silence)
		if not target.Classification(worldboss)
		{
			Spell(arcane_torrent_mana)
			if target.InRange(quaking_palm) Spell(quaking_palm)
			Spell(war_stomp)
		}
	}
}


### Discipline icons.

AddIcon help=main specialization=discipline
{
    UpdateRaidAndParty()
	if BuffStacks(evangelism_buff) == 5 Spell(archangel)
	if target.IsFriend()
	{
		if  InCombat() and target.BuffExpires(weakened_soul_debuff) and { {GetMainTank_ID() > 0 and GetTarget_ID()==GetMainTank_ID()} or {GetOffTank_ID() > 0 and GetTarget_ID()==GetOffTank_ID()} }
		{
			Spell(power_word_shield)
		}
		if InCombat() and { {not focustarget.IsFriend() and focustarget.InRange(holy_fire)} or {not targettarget.IsFriend() and targettarget.InRange(holy_fire)}  } Spell(holy_fire)
		if InCombat() and target.HealthPercent() <= 90 and target.BuffExpires(weakened_soul_debuff) Spell(power_word_shield)
		if target.HealthPercent() <= 50 
		{
			if { Glyph(glyph_of_penance) or  not Speed(more 0)} Spell(penance)
			if not Speed(more 0) Spell(flash_heal)
		}
		if GetGroupMembersNumBelow(70) >= 3 Spell(prayer_of_healing)
		if target.HealthPercent() <= 90 and { Glyph(glyph_of_penance) or  not Speed(more 0)}
		{
			Spell(penance)
		}
		
		if InCombat() and not Speed(more 0) Spell(prayer_of_mending)
		if not Speed(more 0) and InCombat() and BuffExpires(archangel_buff)
		{
			if not focustarget.IsFriend() or not targettarget.IsFriend() Spell(smite)
		}
		
		if BuffPresent(archangel_buff) or not InCombat() and not Speed(more 0)
		{
			if target.HealthPercent() <= 90 Spell(heal)
		}
		CheckBoxOn(opt_auto_movebuff)
		{
			if Talent(5) and Speed(more 0) and DebuffExpires(121557) Spell(angelic_feather)
		}
		
	}
	if not target.IsFriend()
	{
		if InCombat() or CheckBoxOn(opt_auto_autoattack)
		{
			if target.InRange(holy_fire) Spell(holy_fire)
			if not target.DebuffPresent(shadow_word_pain_debuff) or target.DebuffRemaining(shadow_word_pain_debuff) < BaseDuration(shadow_word_pain_debuff) * 0.3 Spell(shadow_word_pain)
			if { Glyph(glyph_of_penance) or  not Speed(more 0)} Spell(penance)
			if not Speed(more 0) Spell(smite)
		}
		if CheckBoxOn(opt_auto_movebuff) and  Speed(more 0) and DebuffExpires(121557) Spell(angelic_feather)
		
	}
	
}



AddIcon help=target specialization=discipline
{	
    
	UpdateRaidAndParty()
	if CheckBoxOn(opt_auto_target)
	{
		if HealthPercent() <= 40
			{return 0}
			else
			{
				if GetLowestHP_HP() <= 20
					{return GetLowestHP_ID()}
				else
				{
					if InCombat() and {MainTankNeedMyBuffDisc() or OffTankNeedMyBuffDisc()}
					{
							if MainTankNeedMyBuffDisc() 
							{
								return GetMainTank_ID()
							}
							else if OffTankNeedMyBuffDisc()
							{
								return GetOffTank_ID()
							}
					}
					else
					{
						if GetLowestHP_HP() < 99
						{
							if GetTarget_ID() == GetLowestHP_ID() and IsPlayer()
							{
								return 100
							}
							else
							{
								return GetLowestHP_ID()
							}
						}
						else
						{
							if GetTarget_ID() == GetMainTank_ID() and IsPlayer()
							{
								return 100
							}
							else
							{
								return GetMainTank_ID()
							}
						}
				
					}
						
				}
			}
	}
}

AddIcon help=distance specialization=discipline
{
	#OffTankNeedMyBuffDisc()
	GetMainTank_ID()
	#AdvancedDistanceFromTarget()
	#Spell(hand_of_sacrifice)
	#MainTankNeedMyBuffDisc()
	#Talent(ethernal_flame_talent)
	#GetLowestHP_ID()
	#GetLowestHP_HP()
	#MyTargetID()
	#Speed()
	#Spell(flash_heal)
	#Speed()
	#Spell(heal)
	#MySpeed()
	#IsPlayer() 
	#Spell(prayer_of_mending)
	#GetTarget_ID()
}

### Required symbols
# arcane_torrent_mana
# berserking
# blood_fury_sp
# borrowed_time_buff
# clarity_of_will
# draenic_intellect_potion
# draenic_mana_potion
# flash_heal
# heal
# mindbender
# mindbender_talent
# penance_heal
# power_infusion
# power_infusion_buff
# power_infusion_talent
# power_word_fortitude
# power_word_shield
# power_word_solace
# power_word_solace_talent
# prayer_of_mending
# quaking_palm
# shadowfiend
# silence
# surge_of_light_buff
# war_stomp
]]
	OvaleScripts:RegisterScript("PRIEST", "discipline", name, desc, code, "script")
end
